\(\int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx\) [552]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 19, antiderivative size = 90 \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=-\frac {b^2 \text {arctanh}\left (\frac {\cos (c+d x) (b-a \tan (c+d x))}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2} d}+\frac {b \cos (c+d x)}{\left (a^2+b^2\right ) d}+\frac {a \sin (c+d x)}{\left (a^2+b^2\right ) d} \]

[Out]

-b^2*arctanh(cos(d*x+c)*(b-a*tan(d*x+c))/(a^2+b^2)^(1/2))/(a^2+b^2)^(3/2)/d+b*cos(d*x+c)/(a^2+b^2)/d+a*sin(d*x
+c)/(a^2+b^2)/d

Rubi [A] (verified)

Time = 0.13 (sec) , antiderivative size = 90, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.263, Rules used = {3592, 3567, 2717, 3590, 212} \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=-\frac {b^2 \text {arctanh}\left (\frac {\cos (c+d x) (b-a \tan (c+d x))}{\sqrt {a^2+b^2}}\right )}{d \left (a^2+b^2\right )^{3/2}}+\frac {a \sin (c+d x)}{d \left (a^2+b^2\right )}+\frac {b \cos (c+d x)}{d \left (a^2+b^2\right )} \]

[In]

Int[Cos[c + d*x]/(a + b*Tan[c + d*x]),x]

[Out]

-((b^2*ArcTanh[(Cos[c + d*x]*(b - a*Tan[c + d*x]))/Sqrt[a^2 + b^2]])/((a^2 + b^2)^(3/2)*d)) + (b*Cos[c + d*x])
/((a^2 + b^2)*d) + (a*Sin[c + d*x])/((a^2 + b^2)*d)

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 2717

Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 3567

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*((d*Sec[
e + f*x])^m/(f*m)), x] + Dist[a, Int[(d*Sec[e + f*x])^m, x], x] /; FreeQ[{a, b, d, e, f, m}, x] && (IntegerQ[2
*m] || NeQ[a^2 + b^2, 0])

Rule 3590

Int[sec[(e_.) + (f_.)*(x_)]/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[-f^(-1), Subst[Int[1/(a^
2 + b^2 - x^2), x], x, (b - a*Tan[e + f*x])/Sec[e + f*x]], x] /; FreeQ[{a, b, e, f}, x] && NeQ[a^2 + b^2, 0]

Rule 3592

Int[((d_.)*sec[(e_.) + (f_.)*(x_)])^(m_)/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[1/(a^2 + b^
2), Int[(d*Sec[e + f*x])^m*(a - b*Tan[e + f*x]), x], x] + Dist[b^2/(d^2*(a^2 + b^2)), Int[(d*Sec[e + f*x])^(m
+ 2)/(a + b*Tan[e + f*x]), x], x] /; FreeQ[{a, b, d, e, f}, x] && NeQ[a^2 + b^2, 0] && ILtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = \frac {\int \cos (c+d x) (a-b \tan (c+d x)) \, dx}{a^2+b^2}+\frac {b^2 \int \frac {\sec (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2+b^2} \\ & = \frac {b \cos (c+d x)}{\left (a^2+b^2\right ) d}+\frac {a \int \cos (c+d x) \, dx}{a^2+b^2}-\frac {b^2 \text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,\cos (c+d x) (b-a \tan (c+d x))\right )}{\left (a^2+b^2\right ) d} \\ & = -\frac {b^2 \text {arctanh}\left (\frac {\cos (c+d x) (b-a \tan (c+d x))}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{3/2} d}+\frac {b \cos (c+d x)}{\left (a^2+b^2\right ) d}+\frac {a \sin (c+d x)}{\left (a^2+b^2\right ) d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.57 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.88 \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=\frac {2 b^2 \text {arctanh}\left (\frac {-b+a \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2+b^2}}\right )+\sqrt {a^2+b^2} (b \cos (c+d x)+a \sin (c+d x))}{\left (a^2+b^2\right )^{3/2} d} \]

[In]

Integrate[Cos[c + d*x]/(a + b*Tan[c + d*x]),x]

[Out]

(2*b^2*ArcTanh[(-b + a*Tan[(c + d*x)/2])/Sqrt[a^2 + b^2]] + Sqrt[a^2 + b^2]*(b*Cos[c + d*x] + a*Sin[c + d*x]))
/((a^2 + b^2)^(3/2)*d)

Maple [A] (verified)

Time = 1.60 (sec) , antiderivative size = 90, normalized size of antiderivative = 1.00

method result size
derivativedivides \(\frac {\frac {2 b^{2} \operatorname {arctanh}\left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}-\frac {2 \left (-a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-b \right )}{\left (a^{2}+b^{2}\right ) \left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}}{d}\) \(90\)
default \(\frac {\frac {2 b^{2} \operatorname {arctanh}\left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}-\frac {2 \left (-a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-b \right )}{\left (a^{2}+b^{2}\right ) \left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}}{d}\) \(90\)
risch \(-\frac {i {\mathrm e}^{i \left (d x +c \right )}}{2 \left (-i b +a \right ) d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )}}{2 \left (i b +a \right ) d}+\frac {b^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {i a^{3}+i a \,b^{2}-a^{2} b -b^{3}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}} d}-\frac {b^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i a^{3}+i a \,b^{2}-a^{2} b -b^{3}}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}}}\right )}{\left (a^{2}+b^{2}\right )^{\frac {3}{2}} d}\) \(174\)

[In]

int(cos(d*x+c)/(a+b*tan(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/d*(2*b^2/(a^2+b^2)^(3/2)*arctanh(1/2*(2*a*tan(1/2*d*x+1/2*c)-2*b)/(a^2+b^2)^(1/2))-2/(a^2+b^2)*(-a*tan(1/2*d
*x+1/2*c)-b)/(1+tan(1/2*d*x+1/2*c)^2))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 187 vs. \(2 (88) = 176\).

Time = 0.27 (sec) , antiderivative size = 187, normalized size of antiderivative = 2.08 \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=\frac {\sqrt {a^{2} + b^{2}} b^{2} \log \left (-\frac {2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt {a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) - a \sin \left (d x + c\right )\right )}}{2 \, a b \cos \left (d x + c\right ) \sin \left (d x + c\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + b^{2}}\right ) + 2 \, {\left (a^{2} b + b^{3}\right )} \cos \left (d x + c\right ) + 2 \, {\left (a^{3} + a b^{2}\right )} \sin \left (d x + c\right )}{2 \, {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} d} \]

[In]

integrate(cos(d*x+c)/(a+b*tan(d*x+c)),x, algorithm="fricas")

[Out]

1/2*(sqrt(a^2 + b^2)*b^2*log(-(2*a*b*cos(d*x + c)*sin(d*x + c) + (a^2 - b^2)*cos(d*x + c)^2 - 2*a^2 - b^2 + 2*
sqrt(a^2 + b^2)*(b*cos(d*x + c) - a*sin(d*x + c)))/(2*a*b*cos(d*x + c)*sin(d*x + c) + (a^2 - b^2)*cos(d*x + c)
^2 + b^2)) + 2*(a^2*b + b^3)*cos(d*x + c) + 2*(a^3 + a*b^2)*sin(d*x + c))/((a^4 + 2*a^2*b^2 + b^4)*d)

Sympy [F]

\[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=\int \frac {\cos {\left (c + d x \right )}}{a + b \tan {\left (c + d x \right )}}\, dx \]

[In]

integrate(cos(d*x+c)/(a+b*tan(d*x+c)),x)

[Out]

Integral(cos(c + d*x)/(a + b*tan(c + d*x)), x)

Maxima [A] (verification not implemented)

none

Time = 0.46 (sec) , antiderivative size = 142, normalized size of antiderivative = 1.58 \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=-\frac {\frac {b^{2} \log \left (\frac {b - \frac {a \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \sqrt {a^{2} + b^{2}}}{b - \frac {a \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (b + \frac {a \sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1}\right )}}{a^{2} + b^{2} + \frac {{\left (a^{2} + b^{2}\right )} \sin \left (d x + c\right )^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}}}}{d} \]

[In]

integrate(cos(d*x+c)/(a+b*tan(d*x+c)),x, algorithm="maxima")

[Out]

-(b^2*log((b - a*sin(d*x + c)/(cos(d*x + c) + 1) + sqrt(a^2 + b^2))/(b - a*sin(d*x + c)/(cos(d*x + c) + 1) - s
qrt(a^2 + b^2)))/(a^2 + b^2)^(3/2) - 2*(b + a*sin(d*x + c)/(cos(d*x + c) + 1))/(a^2 + b^2 + (a^2 + b^2)*sin(d*
x + c)^2/(cos(d*x + c) + 1)^2))/d

Giac [A] (verification not implemented)

none

Time = 0.39 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.31 \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=-\frac {\frac {b^{2} \log \left (\frac {{\left | 2 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, b - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 2 \, b + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{{\left (a^{2} + b^{2}\right )}^{\frac {3}{2}}} - \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + b\right )}}{{\left (a^{2} + b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )}}}{d} \]

[In]

integrate(cos(d*x+c)/(a+b*tan(d*x+c)),x, algorithm="giac")

[Out]

-(b^2*log(abs(2*a*tan(1/2*d*x + 1/2*c) - 2*b - 2*sqrt(a^2 + b^2))/abs(2*a*tan(1/2*d*x + 1/2*c) - 2*b + 2*sqrt(
a^2 + b^2)))/(a^2 + b^2)^(3/2) - 2*(a*tan(1/2*d*x + 1/2*c) + b)/((a^2 + b^2)*(tan(1/2*d*x + 1/2*c)^2 + 1)))/d

Mupad [B] (verification not implemented)

Time = 4.45 (sec) , antiderivative size = 110, normalized size of antiderivative = 1.22 \[ \int \frac {\cos (c+d x)}{a+b \tan (c+d x)} \, dx=\frac {\frac {2\,b}{a^2+b^2}+\frac {2\,a\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{a^2+b^2}}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}-\frac {2\,b^2\,\mathrm {atanh}\left (\frac {a^2\,b+b^3-a\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a^2+b^2\right )}{{\left (a^2+b^2\right )}^{3/2}}\right )}{d\,{\left (a^2+b^2\right )}^{3/2}} \]

[In]

int(cos(c + d*x)/(a + b*tan(c + d*x)),x)

[Out]

((2*b)/(a^2 + b^2) + (2*a*tan(c/2 + (d*x)/2))/(a^2 + b^2))/(d*(tan(c/2 + (d*x)/2)^2 + 1)) - (2*b^2*atanh((a^2*
b + b^3 - a*tan(c/2 + (d*x)/2)*(a^2 + b^2))/(a^2 + b^2)^(3/2)))/(d*(a^2 + b^2)^(3/2))